VERSION 5.00
Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} frmNewContract 
   Caption         =   "Insert Contract Information"
   ClientHeight    =   14000
   ClientLeft      =   0
   ClientTop       =   -12760
   ClientWidth     =   16000
   OleObjectBlob   =   "frmNewContract.frx":0000
   StartUpPosition =   1  'CenterOwner
End
Attribute VB_Name = "frmNewContract"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Written by Jalisa Greene
'Last Modified by Jalisa Greene
'Last Modified 6/11/2014

Option Explicit    '**all variables must be declared**'
Dim rowNum As Integer

Private Sub UserForm_Initialize()
'**CALLED WHEN USER OPENS THE FORM**'

    Dim aCell As Range
    '**ADD DROPDOWN SELECTIONS FOR CONTRACT STATUS**'
    For Each aCell In Worksheets("Pick Lists").Range("L3:L6")
        cmbStatus.AddItem (aCell.Value)
    Next
    '**ADD DROPDOWN SELECTIONS FOR CONTRACT TYPE**'
    For Each aCell In Worksheets("Pick Lists").Range("M3:M5")
        cmbContractType.AddItem (aCell.Value)
    Next
    '**ADD DROPDOWN SELECTIONS FOR CONTRACT SOURCE**'
    For Each aCell In Worksheets("Contract Data").Range("Q1:Q4")
        txtSource.AddItem (aCell.Value)
    Next
    '**ADD CONTRACT ID SELECTIONS FOR ASSOCIATED OLD CONTRACTS **'
    For Each aCell In Worksheets("Contract Data").Range("C10:C1100")
        If aCell.Value <> "" Then cmbOldContract.AddItem (aCell.Value)
    Next
End Sub

Private Sub btnSave1_Click()
'**ACTION SUB RUNS WHEN A USER CLICKS SAVE

Dim msg As Integer

'**CHECK REQUIRED INFO**'
    If txtRepName.Value = "" Then
        msg = MsgBox("You must enter a Rep Name.", vbOKOnly, "Missing Information")
    ElseIf txtVendor.Value = "" Then
        msg = MsgBox("You must enter a Vendor Name.", vbOKOnly, "Missing Information")
    ElseIf txtDateofAgr.Value = "" Then
        msg = MsgBox("You must enter an Effective Date of Agreement.", vbOKOnly, "Missing Information")
    ElseIf txtExpirationDate.Value = "" Then
        msg = MsgBox("You must enter the Current Expiration Date: Month to Month, No Contract, or a Standard Date.", vbOKOnly, "Missing Information")
    ElseIf txtSource.Value = "" Then
        msg = MsgBox("You must select a contract source", vbOKOnly, "Missing Information")
    ElseIf txtUniqueID.Value = "" Then
        msg = MsgBox("You must enter in a Unique ID for this contract to be identified by.", vbOKOnly, "Missing Information")
    Else:
        rowNum = Worksheets("Contract Data").Range("D1000").End(xlUp).Row + 1
        '**DO THE ACTUAL SAVE IF ALL REQUIRED INFO HAS BEEN FILLED**'
        Call SaveInfo
    End If

End Sub

Private Sub SaveInfo()
'**CALLED ONCE REQUIRED FIELDS HAVE BEEN FILLED AND USER WANTS TO SAVE**'

    Worksheets("Contract Data").Range("D" & rowNum).Value = txtVendor.Value
    Worksheets("Contract Data").Range("E" & rowNum).Value = txtSource.Value
    Worksheets("Contract Data").Range("V" & rowNum).Value = txtRepName.Value
    Worksheets("Contract Data").Range("W" & rowNum).Value = txtRepNum.Value
    Worksheets("Contract Data").Range("X" & rowNum).Value = txtRepEmail.Value
    Worksheets("Contract Data").Range("Y" & rowNum).Value = txtClientSig.Value
    Worksheets("Contract Data").Range("F" & rowNum).Value = txtDateofAgr.Value
    Worksheets("Contract Data").Range("G" & rowNum).Value = txtLengthInitTerm.Value
    Worksheets("Contract Data").Range("H" & rowNum).Value = txtInitTermExpiration.Value
    Worksheets("Contract Data").Range("J" & rowNum).Value = txtExpirationDate.Value
    Worksheets("Contract Data").Range("I" & rowNum).Value = txtAutorenewalLength.Value
    
    Worksheets("Contract Data").Range("Q" & rowNum).Value = cmbContractType.Value
    Worksheets("Contract Data").Range("O" & rowNum).Value = txtPriceIncr.Value
    Worksheets("Contract Data").Range("P" & rowNum).Value = txtETFs.Value
    Worksheets("Contract Data").Range("N" & rowNum).Value = txtFuelEnv.Value
    Worksheets("Contract Data").Range("M" & rowNum).Value = txtAvgPercIncr.Value
    Worksheets("Contract Data").Range("AC" & rowNum).Value = txtNotes.Value
    Worksheets("Contract Data").Range("Z" & rowNum).Value = cmbStatus.Value
    Worksheets("Contract Data").Range("AE" & rowNum).Value = txtUniqueID.Value
    Worksheets("Contract Data").Range("AF" & rowNum).Value = cmbOldContract.Value
    Worksheets("Contract Data").Range("AG" & rowNum).Value = txtNumLoc.Value
    Worksheets("Contract Data").Range("AH" & rowNum).Value = txtCSPhone.Value
        
    '**IF DUPLICATE INVOICE SENT BOX CHECKED, PUT A YES IN THAT COLUMN**'
    If Worksheets("Contract Data").Range("AB" & rowNum).Value <> "" Then
        If chkDupInvoice.Value = True Then
            Worksheets("Contract Data").Range("AB" & rowNum).Value = "Yes"
        Else:
            Worksheets("Contract Data").Range("AB" & rowNum).Value = "No"
        End If
    End If
    '**IF PENALTY BOX CHECKED, PUT A YES IN THAT COLUMN**'
    If Worksheets("Contract Data").Range("AA" & rowNum).Value <> "" Then
        If chkPenalty.Value = True Then
            Worksheets("Contract Data").Range("AA" & rowNum).Value = "Yes"
        Else:
            Worksheets("Contract Data").Range("AA" & rowNum).Value = "No"
        End If
    End If
    
        
    Unload frmNewContract
    frmContracts.lstContractList.Clear
    Dim aCell As Range
    
    '**REFRESH CONTRACT LIST ON FIRST PAGE**'
    frmContracts.lstContractList.AddItem (" - Old Contracts -")
    For Each aCell In Worksheets("Contract Data").Range("C10:C1100")
        If Worksheets("Contract Data").Range("E" & aCell.Row).Value = "Current Contract" Then frmContracts.lstContractList.AddItem (Worksheets("Contract Data").Range("C" & aCell.Row).Value)
    Next
    frmContracts.lstContractList.AddItem (" - New Contracts -")
    For Each aCell In Worksheets("Contract Data").Range("C10:C1100")
        If Worksheets("Contract Data").Range("E" & aCell.Row).Value <> "Current Contract" And Worksheets("Contract Data").Range("E" & aCell.Row).Value <> "" Then frmContracts.lstContractList.AddItem (Worksheets("Contract Data").Range("C" & aCell.Row).Value)
    Next
        
    
End Sub

